import numpy as np

data = np.sin(np.arange(20).reshape(5, 4))
print(data)

# 列最大值的编号
idx = data.argmax(axis=0)
print(idx)

# 取出每列的最大值
# 特别常用的用法
data_max = data[idx, range(data.shape[1])]
print(data_max)

# 取出每列最大值
print(data.max(axis=0))
print(data.min(axis=0))

# 取出每行的最大值
print(data.max(axis=1))

print(data.shape[1])

print(all(data_max == data.max(axis=0)))


# 复制
a = np.arange(0, 40, 10)
print(a)
# Construct an array by repeating A the number of times given by reps.
# (3,5) repeating times
b = np.tile(a, (3, 5))
print(b)


# 排序
a = np.array([[3, 5, 4],
              [1, 2, 1]])

b = np.sort(a, axis=1)
print(b)
a.sort(axis=1)
print(a)

a = np.array([4, 3, 1, 2])

# j 为排序的下标
j = np.argsort(a)
print(j)
# 输出排序后的元素
print(a[j])
